<?php
/**
 * Created by Pixoid.
 * Date: 16.03.11
 * @version 1.0
 */
 
define('VIEWS_BASEDIR', dirname(__FILE__).'/../view/');

class View {

    function fetchPartial($template, $params = array()){
        extract($params);
        ob_start();
        include VIEWS_BASEDIR.$template.'.php';
        return ob_get_clean();
    }

    function renderPartial($template, $params = array()){
        echo $this->fetchPartial($template, $params);
    }

    function fetch($template, $params = array()){
        $content = $this->fetchPartial($template, $params);
        return $this->fetchPartial('layout', array('content' => $content));
    }

    function render($template, $params = array()){
        echo $this->fetch($template, $params);
    }
}